﻿namespace SharpObservation
{
    /// <summary>
    ///   Describes any instance which references another instance.
    /// </summary>
    /// <typeparam name = "T">The type being referenced</typeparam>
    /// <remarks>
    ///   Aside from the WeakReference and Garbage Collector pattern, implementations of caching patterns may also
    ///   provide object references which expire over time. The IReference pattern is abstracts this so that collections 
    ///   and other generic types can interoperate.
    /// </remarks>
    public interface IReference<out T>
        where T : class
    {
        // TODO: Consider dropping IsAlive, since it is only relevant in a weakreference context.

        /// <summary>
        ///   Gets whether the target is alive.
        /// </summary>
        bool IsAlive { get; }

        /// <summary>
        ///   Gets or sets the target, or null
        /// </summary>
        T Target { get; }
    }
}